package com.jp.knowledge.my.activity;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;

import com.jiayen.util.ToasUtil;
import com.jp.knowledge.R;
import com.jp.knowledge.comm.SlidingActivity;
import com.jp.knowledge.fragment.DepartmentManagerFragment;
import com.jp.knowledge.my.model.OrganizaModel;

import org.xutils.view.annotation.ViewInject;


/**
 * @author jiayen     2017-03-30 16:16:04
 *  组织架构note
 */
public class DepartmentManagerActivity extends SlidingActivity implements View.OnClickListener {

    @ViewInject(R.id.content_layout)
    private FrameLayout  contentLayout;

    private OrganizaModel company;

    private boolean userEdit;
    @Override
    protected int getResourceId() {
        return R.layout.activity_department_mrg;
    }

    @Override
    protected void init() {

        try {
            company = (OrganizaModel) getIntent().getSerializableExtra("company");
            userEdit = getIntent().getBooleanExtra("userEdit",false);
        }catch (Exception e){

        }
       if(company==null){
           this.finish();
           ToasUtil.toast(mContext,"公司信息为空");
           return;
       }


        topName.setText("组织架构");
        rightIcon.setVisibility(View.GONE);
        leftIcon.setImageResource(R.mipmap.guanzhufanhui);
        leftIcon.setOnClickListener(this);
        leftIcon.setOnClickListener(this);

        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction  transaction  = manager.beginTransaction();
        DepartmentManagerFragment  fragment  = new DepartmentManagerFragment().newInstance(company,userEdit);
        transaction.add(R.id.content_layout,fragment);
        transaction.commit();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.icon_left:
                finish();
                break;
            default:
                break;
        }
    }

}
